HTTP digest authentication fails when request URI ends with '?' #3228
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Using Rails 3.1 and protecting some controller actions with HTTP digest authentication. Some actions accept filter parameters from the query string, and I have a button to "clear all filters". This 'reset' effectively sets the query string to empty, but leaves the '?' on the URI. (1)
In Chrome, this causes the HTTP authentication to fail, while Firefox silently removes the trailing '?' and continues.
Some code examples follow, but I'm not familiar enough with the HTTP specs to say if this is a bug in
ActionController::HttpAuthentication::Digest#validate_digest_response
or if the bug lies inRack::Request#fullpath
. However, I'm filing the issue here as a starting point for discussion.Here's the gist of my controller
STEPS TO REPRODUCE:
In Chrome, the filter reset leaves the URL with a trailing '?'. In FireFox, the '?' is removed. However, if I manually type in the address
http://localhost:3000/secure/secret?
in FireFox, the authentication failure is replicated.